<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>招聘单位反馈信息</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="layui/css/layui.css" media="all">
	<link rel="stylesheet" href="css/public.css" media="all">
	<style type="text/css">
		.layui-table-cell {
			height: auto;
			line-height: 28px;
		}
	</style>
</head>
<body>
<div class="layuimini-container">
	<div class="layuimini-main">
		<script type="text/html" id="toolbarDemo">
			<div class="layui-btn-container">
				<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加反馈 </button>
			</div>
		</script>

		<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter" ></table>

		<script type="text/html" id="currentTableBar">
			<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="detail">详情</a>
		</script>

	</div>
</div>
<script src="layui/layui.js" type="text/javascript" charset="UTF-8"></script>
<script src="js/jquery-3.6.3.js"></script>
<script>

	layui.use(['form', 'table'], function () {
		var $ = layui.jquery,
				form = layui.form,
				table = layui.table;


		table.render({
			elem: '#currentTableId',
			url: '/getOneDepartmentFeedback',
			toolbar: '#toolbarDemo',
			even: true,
			defaultToolbar: ['filter', 'exports', 'print', {
				title: '提示',
				layEvent: 'LAYTABLE_TIPS',
				icon: 'layui-icon-tips'
			}],
			cols: [
					[
						{field: 'id', width: 100,title: '编号', sort: true,align:"center"},
						{field: 'content', width: 1000, title: '反馈信息',align:"center"},
						{field: 'time', width: 200,title: '发送时间',sort: true,align:"center"},
						{title: '操作', minWidth: 200,toolbar: '#currentTableBar', align: "center"}
					]
			],
			limits: [10, 15, 20, 25, 50],
			limit: 10,
			page: true,
			parseData: function (res) { //将原始数据解析成 table 组件所规定的数据，res为从url中get到的数据
			var result;
			if (this.page.curr) {
				result = res.slice(this.limit * (this.page.curr - 1), this.limit * this.page.curr);
			}
			else {
				result = res.slice(0, this.limit);
			}
			return {
				"code": 0, //解析接口状态
				"msg": '', //解析提示文本
				"count": res.length, //解析数据长度
				"data": result //解析数据列表
			};
		}
		});



		/**
		 * toolbar监听事件
		 */
		table.on('toolbar(currentTableFilter)', function (obj) {
			if (obj.event === 'add') {  // 监听添加操作
				var index = layer.open({
					title: '请编辑反馈信息',
					type: 2,
					shade: 0.2,
					maxmin:true,
					shadeClose: true,
					area: ['60%', '60%'],
					content: '/toLxfkIndex',
				});
				$(window).on("resize", function () {
					layer.full(index);
				});
			}
		});


		//监听详情、编辑、删除
		table.on('tool(currentTableFilter)', function (obj) {
			var data1 = obj.data;
			if (obj.event === 'detail') {
				var index = layer.open({
					title:false,
					type: 2,
					shade: 0.2,
					maxmin: false,
					shadeClose: true,
					area: ['700px', '500px'],
					content: '/toFeedbackDetail?id=' + data1.id,
				});
				$(window).on("resize", function () {
					layer.full(index);
				});
				return false;
			}
		})

	});
</script>

</body>
</html>